Skip to content

Match Gamma log-score gradients for small positive targets - #460

Open
rudycelekli wants to merge 1 commit into
stanfordmlgroup:masterfrom
rudycelekli:fix/gamma-gradient-20261104
Open

rudycelekli wants to merge 1 commit into
stanfordmlgroup:masterfrom
rudycelekli:fix/gamma-gradient-20261104

Conversation

@rudycelekli

Copy link
Copy Markdown

The Gamma score uses its actual log density, but the log-shape gradient uses log(epsilon+beta*Y). For small positive targets this clips the derivative substantially: alpha=2, beta=1 and Y=1e-200 gives about 46.90 instead of 921.88.

Compute log(beta)+log(Y), preserving the positive-support derivative without clipping or a potentially underflowing product. Two parameterized cases cover alpha=1/2 and 2, small targets, varied rates and ordinary targets. They use closed-form digamma identities and independent central finite differences of the actual log score.

Validation on Python 3.11.15, scikit-learn 1.6.1, NumPy 2.4.6 and SciPy 1.17.1: this independent branch's regression tests and full configured pre-commit hooks pass. The unchanged upstream slow suite passes 169 tests, with 2 xfailed and 22 xpassed. A private composition of the six proposed fixes passes 201 tests with the same expected/unexpected-pass statuses; final organized regression tests pass all 32 cases and combined lint passes. The production files are identical across that integration run and the final branches; test organization was verified separately.

Implementation and tests are AI-assisted, with additional independent automated correctness/duplicate review. Numerical cases use synthetic fixtures and analytic/SciPy oracles. Hosted CI and maintainer acceptance are separate from these local results.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant